package tliasmanagement.mapper;

import org.apache.ibatis.annotations.*;
import tliasmanagement.pojo.Clazz;
import tliasmanagement.pojo.ClazzQueryParam;

import java.util.List;

@Mapper
public interface ClazzMapper {
    /**
     * 分页查询
     */
    public List<Clazz> getClazzByPage(ClazzQueryParam clazzQueryParam);

    /**
     * 添加班级
     */
    @Insert("insert into clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time) " +
            "values (#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})")
    void add(Clazz clazz);

    /**
     * 根据id查询班级信息
     *
     * @param id 班级id
     */
    Clazz getDetailInfo(Integer id);

    /**
     * 修改班级信息
     *
     * @param clazz 班级信息
     */
    @Update("update clazz set name = #{name}, room = #{room}, begin_date = #{beginDate}, end_date = #{endDate}, update_time = #{updateTime} " +
            "where id = #{id}")
    void update(Clazz clazz);

    /**
     * 删除班级
     *
     * @param id 班级id
     */
    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);

    /**
     * 查询所有班级信息
     */
    @Select("select id, name from clazz")
    List<Clazz> list();
}
